#pragma once

#include "StartObjectBehaviorAction.h"

#include "Behavior.h"
#include "InputPin.h"
#include "Parameter.h"

namespace uml {

StartObjectBehaviorAction::StartObjectBehaviorAction(const QString& umlType)
    : CallAction(umlType) {}

void StartObjectBehaviorAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    CallAction::fromJson(json, errorList);
    object_ = JsonSerializable::create<InputPin>(json.value("object"), errorList);

}

void StartObjectBehaviorAction::toJson(QJsonObject& json) {
    CallAction::toJson(json);
    if (object_) {
        QJsonObject object_json;
        object_->toJson(object_json);
        json.insert("object", object_json);
    }
}

/// <summary>
/// outputParameters
    /// Return the inout, out and return ownedParameters of the Behavior being called.
/// </summary>
    /// <code>
    /// result = (self.behavior().outputParameters())
    /// </code>
shared_ptr<vector<Parameter>> StartObjectBehaviorAction::outputParameters() const
{
    return nullptr;
}

/// <summary>
/// inputParameters
    /// Return the in and inout ownedParameters of the Behavior being called.
/// </summary>
    /// <code>
    /// result = (self.behavior().inputParameters())
    /// </code>
shared_ptr<vector<Parameter>> StartObjectBehaviorAction::inputParameters() const
{
    return nullptr;
}

/// <summary>
/// behavior
    /// If the type of the object InputPin is a Behavior, then that Behavior. Otherwise,
    /// if the type of the object InputPin is a BehavioredClassifier, then the
    /// classifierBehavior of that BehavioredClassifier.
/// </summary>
    /// <code>
    /// result = (if object.type.oclIsKindOf(Behavior) then
    ///   object.type.oclAsType(Behavior)
    /// else if object.type.oclIsKindOf(BehavioredClassifier) then
    ///   object.type.oclAsType(BehavioredClassifier).classifierBehavior
    /// else
    ///   null
    /// endif
    /// endif)
    /// </code>
shared_ptr<Behavior> StartObjectBehaviorAction::behavior() const
{
    return nullptr;
}

/// <summary>
/// object getter
/// An InputPin that holds the object that is either a Behavior to be started or has
/// a classifierBehavior to be started.
/// </summary>
shared_ptr<InputPin> StartObjectBehaviorAction::object() const {
    return object_;
}

/// <summary>
/// object setter
/// An InputPin that holds the object that is either a Behavior to be started or has
/// a classifierBehavior to be started.
/// </summary>
void StartObjectBehaviorAction::setObject(shared_ptr<InputPin> value) {
    object_ = value;
}

} // namespace uml
